@extends('base')

@section('content')
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>ID</th>
            <th>等级名称</th>
            <th>路径</th>
            <th>父级Id</th>
            <th>当前级别</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($levels as $level)

            <tr>
                <td>{{$level->id}}</td>
                <td>{{$level->name}}</td>
                <td>{{$level->path}}</td>
                <td>{{$level->pid}}</td>
                <td>{{$level->level}}</td>
                <td>
                    <a type="button" class="layui-btn layui-btn-normal layui-btn-sm"
                       href="{{route('level.edit',$level)}}">
                        编辑
                    </a>
                    <button class="layui-btn layui-btn-warm layui-btn-sm">删除</button>
                </td>
            </tr>
        @endforeach

        </tbody>
    </table>

@endsection
@section('script')
    <script>
        //更改角色状态
        $(".switch-component").on('click', function () {
            var flow_id = $(this).data('id');
            var status = $(this).is(':checked') ? true : false;
            $.post("{{route('workflows.change')}}", {id: flow_id, status: status}, function (res) {
                layer.msg(res['msg']);
                setInterval('window.location.href= "{{route('workflows.index')}}"', 2000);
            })
        });
    </script>
@endsection
